<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a="http://richfaces.org/a4j"
	template="/layout/template-base.xhtml" contentType="text/html"
	markupType="xhtml">

	<ui:define name="content">
		
		<ui:include src="/user.xhtml" />
		
		<h:form>
			<s:decorate template="/layout/content.xhtml">
				<a:outputPanel rendered="#{solicitudesAction.listarSolicitudes}">
					<h:outputText value="#{messages['editrequest.table.title']}"
						styleClass="title color-orange" />
					<rich:panel styleClass="panel border-color-orange">
						<rich:dataTable columnClasses="data-table-cell" id="requestTable"
							value="#{solicitudesAction.solicitudes}" styleClass="data-table"
							var="item" rows="10">
							<f:facet name="header">
								<rich:columnGroup>
									<rich:column styleClass="data-table-header color-orange">
										<h:outputText value="#{messages['editrequest.table.name']}" />
									</rich:column>
									<rich:column styleClass="data-table-header color-orange">
										<h:outputText value="#{messages['editrequest.table.surname']}" />
									</rich:column>
									<rich:column styleClass="data-table-header color-orange">
										<h:outputText value="#{messages['editrequest.table.lastname']}" />
									</rich:column>
									<rich:column styleClass="data-table-header color-orange">
										<h:outputText value="#{messages['editrequest.table.band.name']}" />
									</rich:column>
									<rich:column styleClass="data-table-header color-orange">
										<h:outputText value="#{messages['editrequest.table.date']}" />
									</rich:column>
									<rich:column styleClass="data-table-header color-orange">
										<h:outputText value="#{messages['editrequest.table.status']}" />
									</rich:column>
									<rich:column styleClass="data-table-header color-orange">
										<h:outputText value="#{messages['editrequest.table.actions']}" />
									</rich:column>
								</rich:columnGroup>
							</f:facet>
							<rich:column>
								<h:outputText value="#{item.nombre}" />
							</rich:column>
							<rich:column>
								<h:outputText value="#{item.primerApellido}" />
							</rich:column>
							<rich:column>
								<h:outputText value="#{item.segundoApellido}" />
							</rich:column>
							<rich:column>
								<h:outputText value="#{item.nombreGrupo}" />
							</rich:column>
							<rich:column>
								<h:outputText value="#{item.fechaEntrada}">
									<s:convertDateTime pattern="dd/MM/yyyy HH:mm" />
								</h:outputText>
							</rich:column>
							<rich:column>
								<h:outputText value="#{messages['editrequest.table.status.pending']}" rendered="#{item.aceptada == null}" />
								<h:outputText value="#{messages['editrequest.table.status.accepted']}" rendered="#{item.aceptada == true}" />
								<h:outputText value="#{messages['editrequest.table.status.rejected']}" rendered="#{item.aceptada == false}" />
							</rich:column>
							<rich:column>
								<a:commandLink action="#{solicitudesAction.editar()}" styleClass="no-border" 
									rendered="#{usuario.perfil.administrador or usuario.perfil.solicitudesModificar}" reRender="base">
									<h:graphicImage value="/img/icons/16/edit.png" alt="#{messages['editrequest.table.actions.edit']}" 
										title="#{messages['editrequest.table.actions.edit']}" />
									<f:setPropertyActionListener target="#{solicitudesAction.solicitud}" value="#{item}" />
								</a:commandLink>
							</rich:column>
						</rich:dataTable>
					</rich:panel>
	
					<rich:datascroller for="requestTable" align="center"
						selectedStyleClass="border-color-orange color-orange"
						styleClass="top-margin" tableStyleClass="border-color-orange no-bg" />
				</a:outputPanel>
				<a:outputPanel rendered="#{solicitudesAction.editarSolicitud}">
					<h:outputText value="#{messages['editrequest.edit.data']}"
						styleClass="title color-blue" />
					<h:panelGrid styleClass="panel border-color-blue" columns="4">
						
						<h:outputText value="#{messages['editrequest.edit.date']}" styleClass="color-blue" />
						<h:outputText value="#{solicitudesAction.solicitud.fechaEntrada}">
							<s:convertDateTime pattern="dd/MM/yyyy HH:mm" />
						</h:outputText>
						
						<h:outputText value="#{messages['editrequest.edit.name']}" styleClass="color-blue" />
						<h:outputText value="#{solicitudesAction.solicitud.nombre}" />
						
						<h:outputText value="#{messages['editrequest.edit.surname']}" styleClass="color-blue" />
						<h:outputText value="#{solicitudesAction.solicitud.primerApellido}" />
						
						<h:outputText value="#{messages['editrequest.edit.lastname']}" styleClass="color-blue" />
						<h:outputText value="#{solicitudesAction.solicitud.segundoApellido}" />
						
						<h:outputText value="#{messages['editrequest.edit.phone']}" styleClass="color-blue" />
						<h:outputText value="#{solicitudesAction.solicitud.fijo}" />
						
						<h:outputText value="#{messages['editrequest.edit.mobile']}" styleClass="color-blue" />
						<h:outputText value="#{solicitudesAction.solicitud.movil}" />
						
						<h:outputText value="#{messages['editrequest.edit.email']}" styleClass="color-blue" />
						<h:outputText value="#{solicitudesAction.solicitud.email}" />
						
						<h:outputText value="#{messages['editrequest.edit.band.name']}" styleClass="color-blue" />
						<h:outputText value="#{solicitudesAction.solicitud.nombreGrupo}" />

					</h:panelGrid>
					
					<s:div styleClass="clear-it" />
					
					<h:outputText value="#{messages['editrequest.edit.comments']}"
						styleClass="title color-green" />
					<h:panelGrid styleClass="panel border-color-green" columns="1">
						<h:inputTextarea value="#{solicitudesAction.solicitud.comentarios}" disabled="true" />
					</h:panelGrid>
					
					<s:div styleClass="clear-it" />
					
					<h:outputText value="#{messages['editrequest.edit.resolution']}"
						styleClass="title color-orange" />
					<h:panelGrid styleClass="panel border-color-orange" columns="1">
						<h:panelGrid columns="2" width="50%">
							<h:outputText value="#{messages['editrequest.edit.status']}" styleClass="color-orange" />
							<h:selectOneMenu value="#{solicitudesAction.solicitud.aceptada}">
								<f:selectItem itemValue="" itemLabel="#{messages['editrequest.edit.status.pending']}" />
								<f:selectItem itemValue="true" itemLabel="#{messages['editrequest.edit.status.accepted']}" />
								<f:selectItem itemValue="false" itemLabel="#{messages['editrequest.edit.status.rejected']}" />
							</h:selectOneMenu>
						</h:panelGrid>
						<h:outputText value="#{messages['editrequest.edit.resolution.comments']}" styleClass="color-orange" />
						<h:inputTextarea value="#{solicitudesAction.solicitud.resolucion}" />
					</h:panelGrid>
				</a:outputPanel>
				
				<a:outputPanel rendered="#{solicitudesAction.estadoSolicitud}">
					<h:outputText value="#{messages['editrequest.edit.data']}"
						styleClass="title color-blue" />
					<h:panelGrid styleClass="panel border-color-blue" columns="4">
						
						<h:outputText value="#{messages['editrequest.edit.name']}" styleClass="color-blue" />
						<h:inputText value="#{solicitudesAction.solicitud.nombre}" />
						
						<h:outputText value="#{messages['editrequest.edit.surname']}" styleClass="color-blue" />
						<h:inputText value="#{solicitudesAction.solicitud.primerApellido}" />
						
						<h:outputText value="#{messages['editrequest.edit.lastname']}" />
						<h:inputText value="#{solicitudesAction.solicitud.segundoApellido}" />
						
						<h:outputText value="#{messages['editrequest.edit.phone']}" />
						<h:inputText value="#{solicitudesAction.solicitud.fijo}" />
						
						<h:outputText value="#{messages['editrequest.edit.mobile']}" />
						<h:inputText value="#{solicitudesAction.solicitud.movil}" />
						
						<h:outputText value="#{messages['editrequest.edit.email']}" styleClass="color-blue" />
						<h:inputText value="#{solicitudesAction.solicitud.email}" />
						
						<h:outputText value="#{messages['editrequest.edit.band.name']}" styleClass="color-blue" />
						<h:inputText value="#{solicitudesAction.solicitud.nombreGrupo}" />
						
					</h:panelGrid>
					
					<div class="clear-it"></div>
					
					<h:outputText value="#{messages['editrequest.edit.comments']}" styleClass="title color-orange" />
					<h:panelGrid styleClass="panel border-color-orange" columns="4">
						<h:inputTextarea value="#{solicitudesAction.solicitud.comentarios}" />
					</h:panelGrid>
					
					<div class="clear-it"></div>
					
					<h:outputText value="#{messages['editrequest.edit.resolution']}"
						styleClass="title color-green" />
					<h:panelGrid styleClass="panel border-color-green" columns="1">
						<h:panelGrid columns="2" width="50%">
							<h:outputText value="#{messages['editrequest.edit.status']}" styleClass="color-green" />
							<h:outputText value="#{messages['editrequest.table.status.pending']}" rendered="#{solicitudesAction.solicitud.aceptada == null}" />
							<h:outputText value="#{messages['editrequest.table.status.accepted']}" rendered="#{solicitudesAction.solicitud.aceptada == true}" />
							<h:outputText value="#{messages['editrequest.table.status.rejected']}" rendered="#{solicitudesAction.solicitud.aceptada == false}" />
							
							<h:outputText value="#{messages['editrequest.edit.resolution.date']}" styleClass="color-green" />
							<h:outputText value="#{solicitudesAction.solicitud.fechaResolucion}">
								<s:convertDateTime pattern="dd/MM/yyyy HH:mm" />
							</h:outputText>
						</h:panelGrid>
						<h:outputText value="#{messages['editrequest.edit.resolution.comments']}" styleClass="color-green" />
						<h:inputTextarea value="#{solicitudesAction.solicitud.resolucion}" disabled="true" />
					</h:panelGrid>
		
				</a:outputPanel>
	
				<div class="clear-it"></div>
			</s:decorate>
			
			<s:decorate template="/layout/buttonbar.xhtml">
				<a:commandButton value="#{messages['editrequest.actions.save']}" actionListener="#{solicitudesAction.guardarEstadoSolicitud()}" styleClass="btn btn-green" 
					rendered="#{(usuario.perfil.administrador or usuario.perfil.solicitudesModificar) and solicitudesAction.editarSolicitud}" reRender="base" />
				<a:commandButton value="#{messages['editrequest.actions.save']}" actionListener="#{solicitudesAction.guardarCambiosSolicitud()}"
					styleClass="btn btn-green" rendered="#{solicitudesAction.estadoSolicitud}" reRender="base" />
				<a:commandButton value="#{messages['editrequest.actions.cancel']}" styleClass="btn btn-orange" reRender="base"
					rendered="#{solicitudesAction.editarSolicitud}" actionListener="#{solicitudesAction.volver()}" />
				<h:commandButton value="#{messages['editrequest.actions.back']}" rendered="#{not solicitudesAction.estadoSolicitud}"
					action="/menu.htm" styleClass="btn btn-blue" />
				<h:commandButton value="#{messages['editrequest.actions.index']}" rendered="#{solicitudesAction.estadoSolicitud}" 
					action="/index.htm" styleClass="btn btn-blue">
					<s:conversationPropagation type="end" />
				</h:commandButton>
			</s:decorate>
		</h:form>
	</ui:define>
	
</ui:composition>